package com.text.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.text.dao.CategoryDao;
import com.text.entity.Category;
import com.text.entity.Goods;
import com.text.service.CategoryService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Resource
    CategoryDao categoryDao;
    @Override
    public ArrayList<Category> queryAll() {
        return categoryDao.queryAll();
    }
    @Override
    public PageInfo<Category> queryAllByPage(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        ArrayList<Category> categories = categoryDao.queryAll();
        PageInfo<Category> pageInfo = new PageInfo<>(categories);
        return pageInfo;
    }

    @Override
    public int deleteById(Integer id) {
        return this.categoryDao.deleteById(id);
    }

    @Override
    public int insert(Category category) {
        int num = this.categoryDao.insert(category);
        return num;
    }

    @Override
    public Category edit(int id) {
        Category edit = categoryDao.edit(id);
        return edit;
    }

    @Override
    public int update(Category edit) {
        return this.categoryDao.update(edit);
    }
}
